this._proxy.UserExtensionsEnabled = enable;
}
- ListExtensionsAsync(params, invocation) {
- this._proxy.ListExtensionsRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async ListExtensionsAsync(params, invocation) {
+ try {
+ const res = await this._proxy.ListExtensionsAsync(...params);
invocation.return_value(new GLib.Variant('(a{sa{sv}})', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetExtensionInfoAsync(params, invocation) {
- this._proxy.GetExtensionInfoRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetExtensionInfoAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetExtensionInfoAsync(...params);
invocation.return_value(new GLib.Variant('(a{sv})', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetExtensionErrorsAsync(params, invocation) {
- this._proxy.GetExtensionErrorsRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetExtensionErrorsAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetExtensionErrorsAsync(...params);
invocation.return_value(new GLib.Variant('(as)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- InstallRemoteExtensionAsync(params, invocation) {
- this._proxy.InstallRemoteExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async InstallRemoteExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.InstallRemoteExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(s)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- UninstallExtensionAsync(params, invocation) {
- this._proxy.UninstallExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async UninstallExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.UninstallExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- EnableExtensionAsync(params, invocation) {
- this._proxy.EnableExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async EnableExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.EnableExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- DisableExtensionAsync(params, invocation) {
- this._proxy.DisableExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async DisableExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.DisableExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
LaunchExtensionPrefsAsync([uuid], invocation) {
this.OpenExtensionPrefsAsync([uuid, '', {}], invocation);
}
- OpenExtensionPrefsAsync(params, invocation) {
+ async OpenExtensionPrefsAsync(params, invocation) {
const [uuid, parentWindow, options] = params;
- this._proxy.GetExtensionInfoRemote(uuid, (res, error) => {
- if (this._handleError(invocation, error))
- return;
+ try {
+ const [serialized] = await this._proxy.GetExtensionInfoAsync(uuid);
- if (this._prefsDialog) {
- this._handleError(invocation,
- new Error('Already showing a prefs dialog'));
- return;
- }
+ if (this._prefsDialog)
+ throw new Error('Already showing a prefs dialog');
- const [serialized] = res;
const extension = ExtensionUtils.deserializeExtension(serialized);
this._prefsDialog = new ExtensionPrefsDialog(extension);
this._prefsDialog.show();
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- CheckForUpdatesAsync(params, invocation) {
- this._proxy.CheckForUpdatesRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async CheckForUpdatesAsync(params, invocation) {
+ try {
+ await this._proxy.CheckForUpdatesAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
};
'sender-pid': new GLib.Variant('u', pid),
};
- this._proxy.NotifyRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
- const [id] = res;
+ try {
+ const [id] = await this._proxy.NotifyAsync(...params);
this._activeNotifications.set(id, sender);
- invocation.return_value(new GLib.Variant('(u)', res));
- });
+ invocation.return_value(new GLib.Variant('(u)', [id]));
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- CloseNotificationAsync(params, invocation) {
+ async CloseNotificationAsync(params, invocation) {
const [id] = params;
if (!this._checkNotificationId(invocation, id))
return;
- this._proxy.CloseNotificationRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ try {
+ await this._proxy.CloseNotificationAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetCapabilitiesAsync(params, invocation) {
- this._proxy.GetCapabilitiesRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetCapabilitiesAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetCapabilitiesAsync(...params);
invocation.return_value(new GLib.Variant('(as)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetServerInformationAsync(params, invocation) {
- this._proxy.GetServerInformationRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetServerInformationAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetServerInformationAsync(...params);
invocation.return_value(new GLib.Variant('(ssss)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
async _getSenderPid(sender) {
() => this._dbusImpl.emit_signal('WakeUpScreen', null));
}
- LockAsync(params, invocation) {
- this._proxy.LockRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async LockAsync(params, invocation) {
+ try {
+ await this._proxy.LockAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetActiveAsync(params, invocation) {
- this._proxy.GetActiveRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetActiveAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetActiveAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- SetActiveAsync(params, invocation) {
- this._proxy.SetActiveRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async SetActiveAsync(params, invocation) {
+ try {
+ await this._proxy.SetActiveAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetActiveTimeAsync(params, invocation) {
- this._proxy.GetActiveTimeRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetActiveTimeAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetActiveTimeAsync(...params);
invocation.return_value(new GLib.Variant('(u)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
};
release() {
Service(Gio.DBus.system,
- 'org.freedesktop.realmd',
- '/org/freedesktop/realmd',
- service => service.ReleaseRemote());
+ 'org.freedesktop.realmd',
+ '/org/freedesktop/realmd',
+ service => service.ReleaseAsync().catch(logError));
this._aggregateProvider.disconnectObject(this);
this._realms = { };
this._updateLoginFormat();
this.emit('show-message', null, null, MessageType.NONE);
}
- _checkForFingerprintReader() {
+ async _checkForFingerprintReader() {
this._fingerprintReaderType = FingerprintReaderType.NONE;
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY) ||
return;
}
- this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable,
- (params, error) => {
- if (!error && params) {
- const [device] = params;
- const fprintDeviceProxy = new FprintDeviceProxy(Gio.DBus.system,
- 'net.reactivated.Fprint',
- device);
- const fprintDeviceType = fprintDeviceProxy['scan-type'];
-
- this._fingerprintReaderType = fprintDeviceType === 'swipe'
- ? FingerprintReaderType.SWIPE
- : FingerprintReaderType.PRESS;
- this._updateDefaultService();
- }
- });
+ try {
+ const [device] = await this._fprintManager.GetDefaultDeviceAsync(
+ Gio.DBusCallFlags.NONE, this._cancellable);
+ const fprintDeviceProxy = new FprintDeviceProxy(Gio.DBus.system,
+ 'net.reactivated.Fprint',
+ device);
+ const fprintDeviceType = fprintDeviceProxy['scan-type'];
+
+ this._fingerprintReaderType = fprintDeviceType === 'swipe'
+ ? FingerprintReaderType.SWIPE
+ : FingerprintReaderType.PRESS;
+ this._updateDefaultService();
+ } catch (e) {}
}
_onCredentialManagerAuthenticated(credentialManager, _token) {
this._proxy.connectSignal('RegistrationInfo', (proxy, sender, [_status, code, name]) => {
this._setOperatorName(_findProviderForMccMnc(name, code));
});
- this._proxy.GetRegistrationInfoRemote(([result], err) => {
- if (err) {
- log(err);
- return;
- }
+ this._getInitialState();
+ }
- let [status_, code, name] = result;
+ async _getInitialState() {
+ try {
+ const [
+ [status_, code, name],
+ [quality],
+ ] = await Promise.all([
+ this._proxy.GetRegistrationInfoAsync(),
+ this._proxy.GetSignalQualityAsync(),
+ ]);
this._setOperatorName(_findProviderForMccMnc(name, code));
- });
- this._proxy.GetSignalQualityRemote((result, err) => {
- if (err) {
- // it will return an error if the device is not connected
- this._setSignalQuality(0);
- } else {
- let [quality] = result;
- this._setSignalQuality(quality);
- }
- });
+ this._setSignalQuality(quality);
+ } catch (err) {
+ // it will return an error if the device is not connected
+ this._setSignalQuality(0);
+ }
}
});
if (this.operator_name == null)
this._refreshServingSystem();
});
- this._proxy.GetSignalQualityRemote((result, err) => {
- if (err) {
- // it will return an error if the device is not connected
- this._setSignalQuality(0);
- } else {
- let [quality] = result;
- this._setSignalQuality(quality);
- }
- });
+ this._getSignalQuality();
}
- _refreshServingSystem() {
- this._proxy.GetServingSystemRemote(([result], err) => {
- if (err) {
- // it will return an error if the device is not connected
- this._setOperatorName(null);
- } else {
- let [bandClass_, band_, sid] = result;
- this._setOperatorName(_findProviderForSid(sid));
- }
- });
+ async _getSignalQuality() {
+ try {
+ const [quality] = await this._proxy.GetSignalQualityAsync();
+ this._setSignalQuality(quality);
+ } catch (err) {
+ // it will return an error if the device is not connected
+ this._setSignalQuality(0);
+ }
+ }
+
+ async _refreshServingSystem() {
+ try {
+ const [bandClass_, band_, sid] =
+ await this._proxy.GetServingSystemAsync();
+ this._setOperatorName(_findProviderForSid(sid));
+ } catch (err) {
+ // it will return an error if the device is not connected
+ this._setOperatorName(null);
+ }
}
});
this.notify('can-lock-screen');
}
- _updateHaveShutdown() {
- this._session.CanShutdownRemote((result, error) => {
- this._canHavePowerOff = error ? false : result[0];
- this._updatePowerOff();
- });
+ async _updateHaveShutdown() {
+ try {
+ const [canShutdown] = await this._session.CanShutdownAsync();
+ this._canHavePowerOff = canShutdown;
+ } catch (e) {
+ this._canHavePowerOff = false;
+ }
+ this._updatePowerOff();
}
_updatePowerOff() {
throw new Error('The logout action is not available!');
Main.overview.hide();
- this._session.LogoutRemote(0);
+ this._session.LogoutAsync(0).catch(logError);
}
activatePowerOff() {
if (!this._actions.get(POWER_OFF_ACTION_ID).available)
throw new Error('The power-off action is not available!');
- this._session.ShutdownRemote(0);
+ this._session.ShutdownAsync(0).catch(logError);
}
activateRestart() {
if (!this._actions.get(RESTART_ACTION_ID).available)
throw new Error('The restart action is not available!');
- this._session.RebootRemote();
+ this._session.RebootAsync().catch(logError);
}
activateSuspend() {
this._needsAuth = true;
this._weatherAuthorized = false;
- this._permStore = new PermissionStore.PermissionStore((proxy, error) => {
+ this._permStore = new PermissionStore.PermissionStore(async (proxy, error) => {
if (error) {
log(`Failed to connect to permissionStore: ${error.message}`);
return;
return;
}
- this._permStore.LookupRemote('gnome', 'geolocation', (res, err) => {
- if (err)
- log(`Error looking up permission: ${err.message}`);
+ let [perms, data] = [{}, null];
+ try {
+ [perms, data] = await this._permStore.LookupAsync('gnome', 'geolocation');
+ } catch (err) {
+ log(`Error looking up permission: ${err.message}`);
+ }
- let [perms, data] = err ? [{}, null] : res;
- let params = ['gnome', 'geolocation', false, data, perms];
- this._onPermStoreChanged(this._permStore, '', params);
- });
+ const params = ['gnome', 'geolocation', false, data, perms];
+ this._onPermStoreChanged(this._permStore, '', params);
});
this._permStore.connectSignal('Changed',
this._onPermStoreChanged.bind(this));
this._events.clear();
this.emit('changed');
}
- this._dbusProxy.SetTimeRangeRemote(
+ this._dbusProxy.SetTimeRangeAsync(
this._curRequestBegin.getTime() / 1000,
this._curRequestEnd.getTime() / 1000,
forceReload,
- Gio.DBusCallFlags.NONE);
+ Gio.DBusCallFlags.NONE).catch(logError);
}
}
}
}
- _InhibitorsChanged(_object, _senderName, [_inhibitor]) {
- this._session.IsInhibitedRemote(GNOME_SESSION_AUTOMOUNT_INHIBIT,
- (result, error) => {
- if (!error)
- this._inhibited = result[0];
- });
+ async _InhibitorsChanged(_object, _senderName, [_inhibitor]) {
+ try {
+ const [inhibited] =
+ await this._session.IsInhibitedAsync(GNOME_SESSION_AUTOMOUNT_INHIBIT);
+ this._inhibited = inhibited;
+ } catch (e) {}
}
_startupMountAll() {
this._confirm('ConfirmedReboot');
}
- _confirm(signal) {
- let callback = () => {
- this._fadeOutDialog();
- this._stopTimer();
- this._stopAltCapture();
- this._dbusImpl.emit_signal(signal, null);
- };
-
- // Offline update not available; just emit the signal
- if (!this._checkBox.visible) {
- callback();
- return;
- }
-
- // Trigger the offline update as requested
- if (this._checkBox.checked) {
- switch (signal) {
- case "ConfirmedReboot":
- this._triggerOfflineUpdateReboot(callback);
- break;
- case "ConfirmedShutdown":
- // To actually trigger the offline update, we need to
- // reboot to do the upgrade. When the upgrade is complete,
- // the computer will shut down automatically.
- signal = "ConfirmedReboot";
- this._triggerOfflineUpdateShutdown(callback);
- break;
- default:
- callback();
- break;
+ async _confirm(signal) {
+ if (this._checkBox.visible) {
+ // Trigger the offline update as requested
+ if (this._checkBox.checked) {
+ switch (signal) {
+ case 'ConfirmedReboot':
+ await this._triggerOfflineUpdateReboot();
+ break;
+ case 'ConfirmedShutdown':
+ // To actually trigger the offline update, we need to
+ // reboot to do the upgrade. When the upgrade is complete,
+ // the computer will shut down automatically.
+ signal = 'ConfirmedReboot';
+ await this._triggerOfflineUpdateShutdown();
+ break;
+ default:
+ break;
+ }
+ } else {
+ await this._triggerOfflineUpdateCancel();
}
- } else {
- this._triggerOfflineUpdateCancel(callback);
}
+
+ this._fadeOutDialog();
+ this._stopTimer();
+ this._stopAltCapture();
+ this._dbusImpl.emit_signal(signal, null);
}
_onOpened() {
this._sync();
}
- _triggerOfflineUpdateReboot(callback) {
+ async _triggerOfflineUpdateReboot() {
// Handle this gracefully if PackageKit is not available.
- if (!this._pkOfflineProxy) {
- callback();
+ if (!this._pkOfflineProxy)
return;
- }
- this._pkOfflineProxy.TriggerRemote('reboot', (result, error) => {
- if (error)
- log(error.message);
-
- callback();
- });
+ try {
+ await this._pkOfflineProxy.TriggerAsync('reboot');
+ } catch (error) {
+ log(error.message);
+ }
}
- _triggerOfflineUpdateShutdown(callback) {
+ async _triggerOfflineUpdateShutdown() {
// Handle this gracefully if PackageKit is not available.
- if (!this._pkOfflineProxy) {
- callback();
+ if (!this._pkOfflineProxy)
return;
- }
-
- this._pkOfflineProxy.TriggerRemote('power-off', (result, error) => {
- if (error)
- log(error.message);
- callback();
- });
+ try {
+ await this._pkOfflineProxy.TriggerAsync('power-off');
+ } catch (error) {
+ log(error.message);
+ }
}
- _triggerOfflineUpdateCancel(callback) {
+ async _triggerOfflineUpdateCancel() {
// Handle this gracefully if PackageKit is not available.
- if (!this._pkOfflineProxy) {
- callback();
+ if (!this._pkOfflineProxy)
return;
- }
- this._pkOfflineProxy.CancelRemote((result, error) => {
- if (error)
- log(error.message);
-
- callback();
- });
+ try {
+ await this._pkOfflineProxy.CancelAsync();
+ } catch (error) {
+ log(error.message);
+ }
}
_startTimer() {
return this._app && !this._app.is_window_backed();
}
- _saveToPermissionStore(grant) {
+ async _saveToPermissionStore(grant) {
if (!this._shouldUsePermStore() || this._permStore == null)
return;
permissions[this._app.get_id()] = [grant];
let data = GLib.Variant.new('av', {});
- this._permStore.SetRemote(APP_PERMISSIONS_TABLE,
- true,
- APP_PERMISSIONS_ID,
- permissions,
- data,
- (result, error) => {
- if (error != null)
- log(error.message);
- });
+ try {
+ await this._permStore.SetAsync(APP_PERMISSIONS_TABLE,
+ true,
+ APP_PERMISSIONS_ID,
+ permissions,
+ data);
+ } catch (error) {
+ log(error.message);
+ }
}
_buildLayout() {
/* Check with the permission store */
let appId = this._app.get_id();
- this._permStore = new PermissionStore.PermissionStore((proxy, error) => {
+ this._permStore = new PermissionStore.PermissionStore(async (proxy, error) => {
if (error) {
log(error.message);
this._dialog.open();
return;
}
- this._permStore.LookupRemote(APP_PERMISSIONS_TABLE,
- APP_PERMISSIONS_ID,
- (res, err) => {
- if (err) {
- this._dialog.open();
- log(err.message);
- return;
- }
-
- let [permissions] = res;
- if (permissions[appId] === undefined) // Not found
- this._dialog.open();
- else if (permissions[appId] == GRANTED)
- this._emitResponse(DialogResponse.ALLOW);
- else
- this._emitResponse(DialogResponse.DENY);
- });
+ try {
+ const [permissions] = await this._permStore.LookupAsync(
+ APP_PERMISSIONS_TABLE, APP_PERMISSIONS_ID);
+
+ if (permissions[appId] === undefined) // Not found
+ this._dialog.open();
+ else if (permissions[appId] === GRANTED)
+ this._emitResponse(DialogResponse.ALLOW);
+ else
+ this._emitResponse(DialogResponse.DENY);
+ } catch (err) {
+ this._dialog.open();
+ log(err.message);
+ }
});
}
}
playPause() {
- this._playerProxy.PlayPauseRemote();
+ this._playerProxy.PlayPauseAsync().catch(logError);
}
get canGoNext() {
}
next() {
- this._playerProxy.NextRemote();
+ this._playerProxy.NextAsync().catch(logError);
}
get canGoPrevious() {
}
previous() {
- this._playerProxy.PreviousRemote();
+ this._playerProxy.PreviousAsync().catch(logError);
}
raise() {
if (app)
app.activate();
else if (this._mprisProxy.CanRaise)
- this._mprisProxy.RaiseRemote();
+ this._mprisProxy.RaiseAsync().catch(logError);
}
_close() {
this._players.set(busName, player);
}
- _onProxyReady() {
- this._proxy.ListNamesRemote(([names]) => {
- names.forEach(name => {
- if (!name.startsWith(MPRIS_PLAYER_PREFIX))
- return;
+ async _onProxyReady() {
+ const [names] = await this._proxy.ListNamesAsync();
+ names.forEach(name => {
+ if (!name.startsWith(MPRIS_PLAYER_PREFIX))
+ return;
- this._addPlayer(name);
- });
+ this._addPlayer(name);
});
this._proxy.connectSignal('NameOwnerChanged',
this._onNameOwnerChanged.bind(this));
return new MessageTray.NotificationApplicationPolicy(this._appId);
}
- _createApp(callback) {
- return new FdoApplicationProxy(Gio.DBus.session, this._appId, this._objectPath, callback);
+ _createApp() {
+ return new Promise((resolve, reject) => {
+ new FdoApplicationProxy(Gio.DBus.session,
+ this._appId, this._objectPath, (proxy, err) => {
+ if (err)
+ reject(err);
+ else
+ resolve(proxy);
+ });
+ });
}
_createNotification(params) {
return new GtkNotificationDaemonNotification(this, params);
}
- activateAction(actionId, target) {
- this._createApp((app, error) => {
- if (error == null)
- app.ActivateActionRemote(actionId, target ? [target] : [], getPlatformData());
- else
- logError(error, 'Failed to activate application proxy');
- });
+ async activateAction(actionId, target) {
+ try {
+ const app = await this._createApp();
+ const params = target ? [target] : [];
+ app.ActivateActionAsync(actionId, params, getPlatformData());
+ } catch (error) {
+ logError(error, 'Failed to activate application proxy');
+ }
Main.overview.hide();
Main.panel.closeCalendar();
}
- open() {
- this._createApp((app, error) => {
- if (error == null)
- app.ActivateRemote(getPlatformData());
- else
- logError(error, 'Failed to open application proxy');
- });
+ async open() {
+ try {
+ const app = await this._createApp();
+ app.ActivateAsync(getPlatformData());
+ } catch (error) {
+ logError(error, 'Failed to open application proxy');
+ }
Main.overview.hide();
Main.panel.closeCalendar();
}
}
activateResult(id) {
- this.proxy.ActivateResultRemote(id);
+ this.proxy.ActivateResultAsync(id).catch(logError);
}
launchSearch(_terms) {
}
activateResult(id, terms) {
- this.proxy.ActivateResultRemote(id, terms, global.get_current_time());
+ this.proxy.ActivateResultAsync(
+ id, terms, global.get_current_time()).catch(logError);
}
launchSearch(terms) {
- this.proxy.LaunchSearchRemote(terms, global.get_current_time());
+ this.proxy.LaunchSearchAsync(
+ terms, global.get_current_time()).catch(logError);
}
};
this.emit('locked-changed');
if (this._loginSession)
- this._loginSession.SetLockedHintRemote(locked);
+ this._loginSession.SetLockedHintAsync(locked).catch(logError);
}
_activateDialog() {
this.close(true);
// This is a bit awkward because creating a proxy synchronously hangs Shell.
- const doStartScreencast = () => {
+ const doStartScreencast = async () => {
let method =
- this._screencastProxy.ScreencastRemote.bind(this._screencastProxy);
+ this._screencastProxy.ScreencastAsync.bind(this._screencastProxy);
if (w !== -1) {
- method = this._screencastProxy.ScreencastAreaRemote.bind(
+ method = this._screencastProxy.ScreencastAreaAsync.bind(
this._screencastProxy, x, y, w, h);
}
- method(
- GLib.build_filenamev([
- /* Translators: this is the folder where recorded
- screencasts are stored. */
- _('Screencasts'),
- /* Translators: this is a filename used for screencast
- * recording, where "%d" and "%t" date and time, e.g.
- * "Screencast from 07-17-2013 10:00:46 PM.webm" */
- /* xgettext:no-c-format */
- _('Screencast from %d %t.webm'),
- ]),
- { 'draw-cursor': new GLib.Variant('b', drawCursor) },
- ([success, path], error) => {
- if (error !== null) {
- this._setScreencastInProgress(false);
- log(`Error starting screencast: ${error.message}`);
- return;
- }
-
- if (!success) {
- this._setScreencastInProgress(false);
- log('Error starting screencast');
- return;
- }
-
- this._screencastPath = path;
- }
- );
+ try {
+ const [success, path] = await method(
+ GLib.build_filenamev([
+ /* Translators: this is the folder where recorded
+ screencasts are stored. */
+ _('Screencasts'),
+ /* Translators: this is a filename used for screencast
+ * recording, where "%d" and "%t" date and time, e.g.
+ * "Screencast from 07-17-2013 10:00:46 PM.webm" */
+ /* xgettext:no-c-format */
+ _('Screencast from %d %t.webm'),
+ ]),
+ {'draw-cursor': new GLib.Variant('b', drawCursor)});
+ if (!success)
+ throw new Error();
+ this._screencastPath = path;
+ } catch (error) {
+ this._setScreencastInProgress(false);
+ const {message} = error;
+ if (message)
+ log(`Error starting screencast: ${message}`);
+ else
+ log('Error starting screencast');
+ }
};
// Set this before calling the method as the screen recording indicator
}
}
- stopScreencast() {
+ async stopScreencast() {
if (!this._screencastInProgress)
return;
// will check it before the success callback fires.
this._setScreencastInProgress(false);
- this._screencastProxy.StopScreencastRemote((success, error) => {
- if (error !== null) {
- log(`Error stopping screencast: ${error.message}`);
- return;
- }
-
- if (!success) {
+ try {
+ const [success] = await this._screencastProxy.StopScreencastAsync();
+ if (!success)
+ throw new Error();
+ } catch (error) {
+ const {message} = error;
+ if (message)
+ log(`Error stopping screencast: ${message}`);
+ else
log('Error stopping screencast');
- return;
- }
+ return;
+ }
- // Show a notification.
- const file = Gio.file_new_for_path(this._screencastPath);
+ // Show a notification.
+ const file = Gio.file_new_for_path(this._screencastPath);
- const source = new MessageTray.Source(
- // Translators: notification source name.
- _('Screenshot'),
- 'screencast-recorded-symbolic'
- );
- const notification = new MessageTray.Notification(
- source,
- // Translators: notification title.
- _('Screencast recorded'),
- // Translators: notification body when a screencast was recorded.
- _('Click here to view the video.')
- );
- // Translators: button on the screencast notification.
- notification.addAction(_('Show in Files'), () => {
- const app =
- Gio.app_info_get_default_for_type('inode/directory', false);
-
- if (app === null) {
- // It may be null e.g. in a toolbox without nautilus.
- log('Error showing in files: no default app set for inode/directory');
- return;
- }
+ const source = new MessageTray.Source(
+ // Translators: notification source name.
+ _('Screenshot'),
+ 'screencast-recorded-symbolic'
+ );
+ const notification = new MessageTray.Notification(
+ source,
+ // Translators: notification title.
+ _('Screencast recorded'),
+ // Translators: notification body when a screencast was recorded.
+ _('Click here to view the video.')
+ );
+ // Translators: button on the screencast notification.
+ notification.addAction(_('Show in Files'), () => {
+ const app =
+ Gio.app_info_get_default_for_type('inode/directory', false);
- app.launch([file], global.create_app_launch_context(0, -1));
- });
- notification.connect('activated', () => {
- try {
- Gio.app_info_launch_default_for_uri(
- file.get_uri(), global.create_app_launch_context(0, -1));
- } catch (err) {
- logError(err, 'Error opening screencast');
- }
- });
- notification.setTransient(true);
+ if (app === null) {
+ // It may be null e.g. in a toolbox without nautilus.
+ log('Error showing in files: no default app set for inode/directory');
+ return;
+ }
- Main.messageTray.add(source);
- source.showNotification(notification);
+ app.launch([file], global.create_app_launch_context(0, -1));
+ });
+ notification.connect('activated', () => {
+ try {
+ Gio.app_info_launch_default_for_uri(
+ file.get_uri(), global.create_app_launch_context(0, -1));
+ } catch (err) {
+ logError(err, 'Error opening screencast');
+ }
});
+ notification.setTransient(true);
+
+ Main.messageTray.add(source);
+ source.showNotification(notification);
}
get screencast_in_progress() {
Util.trySpawnCommandLine(command);
}
-function _callRemote(obj, method, ...args) {
- return new Promise((resolve, reject) => {
- args.push((result, excp) => {
- if (excp)
- reject(excp);
- else
- resolve();
- });
-
- method.apply(obj, args);
- });
-}
-
/**
* createTestWindow:
* @param {Object} params: options for window creation.
});
let perfHelper = _getPerfHelper();
- return _callRemote(perfHelper, perfHelper.CreateWindowRemote,
- params.width, params.height,
- params.alpha, params.maximized, params.redraws);
+ perfHelper.CreateWindowAsync(
+ params.width, params.height,
+ params.alpha, params.maximized, params.redraws).catch(logError);
}
/**
*/
function waitTestWindows() {
let perfHelper = _getPerfHelper();
- return _callRemote(perfHelper, perfHelper.WaitWindowsRemote);
+ perfHelper.WaitWindowsAsync().catch(logError);
}
/**
*/
function destroyTestWindows() {
let perfHelper = _getPerfHelper();
- return _callRemote(perfHelper, perfHelper.DestroyWindowsRemote);
+ perfHelper.DestroyWindowsAsync().catch(logError);
}
/**
return true;
}
- _onManagerProxyReady(proxy, error) {
+ async _onManagerProxyReady(proxy, error) {
if (error != null) {
log(error.message);
this._connecting = false;
this.notify('in-use');
- this._managerProxy.AddAgentRemote('gnome-shell', this._onAgentRegistered.bind(this));
- }
-
- _onAgentRegistered(result, error) {
- this._connecting = false;
- this._notifyMaxAccuracyLevel();
-
- if (error != null)
- log(error.message);
+ try {
+ await this._managerProxy.AddAgentAsync('gnome-shell');
+ this._connecting = false;
+ this._notifyMaxAccuracyLevel();
+ } catch (e) {
+ log(e.message);
+ }
}
_onGeoclueVanished() {
return this._accuracyLevel;
}
- _saveToPermissionStore() {
+ async _saveToPermissionStore() {
if (this._permStoreProxy == null)
return;
let data = GLib.Variant.new('av', {});
- this._permStoreProxy.SetRemote(APP_PERMISSIONS_TABLE,
- true,
- APP_PERMISSIONS_ID,
- this._permissions,
- data,
- (result, error) => {
- if (error != null)
- log(error.message);
- });
+ try {
+ await this._permStoreProxy.SetAsync(
+ APP_PERMISSIONS_TABLE,
+ true,
+ APP_PERMISSIONS_ID,
+ this._permissions,
+ data);
+ } catch (error) {
+ log(error.message);
+ }
}
};
};
const PortalHelperIface = loadInterfaceXML('org.gnome.Shell.PortalHelper');
-const PortalHelperProxy = Gio.DBusProxy.makeProxyWrapper(PortalHelperIface);
+const PortalHelperInfo = Gio.DBusInterfaceInfo.new_for_xml(PortalHelperIface);
function signalToIcon(value) {
if (value < 20)
_flushConnectivityQueue() {
if (this._portalHelperProxy) {
for (let item of this._connectivityQueue)
- this._portalHelperProxy.CloseRemote(item);
+ this._portalHelperProxy.CloseAsync(item).catch(logError);
}
this._connectivityQueue = [];
if (index >= 0) {
if (this._portalHelperProxy)
- this._portalHelperProxy.CloseRemote(path);
+ this._portalHelperProxy.CloseAsync(path).catch(logError);
this._connectivityQueue.splice(index, 1);
}
}
}
- _syncConnectivity() {
+ async _syncConnectivity() {
if (this._mainConnection == null ||
this._mainConnection.state != NM.ActiveConnectionState.ACTIVATED) {
this._flushConnectivityQueue();
}
let timestamp = global.get_current_time();
- if (this._portalHelperProxy) {
- this._portalHelperProxy.AuthenticateRemote(path, '', timestamp);
- } else {
- new PortalHelperProxy(Gio.DBus.session,
- 'org.gnome.Shell.PortalHelper',
- '/org/gnome/Shell/PortalHelper',
- (proxy, error) => {
- if (error) {
- log(`Error launching the portal helper: ${error}`);
- return;
- }
-
- this._portalHelperProxy = proxy;
- proxy.connectSignal('Done', this._portalHelperDone.bind(this));
-
- proxy.AuthenticateRemote(path, '', timestamp);
- });
+ if (!this._portalHelperProxy) {
+ this._portalHelperProxy = new Gio.DBusProxy({
+ g_connection: Gio.DBus.session,
+ g_name: 'org.gnome.Shell.PortalHelper',
+ g_object_path: '/org/gnome/Shell/PortalHelper',
+ g_interface_name: PortalHelperInfo.name,
+ g_interface_info: PortalHelperInfo,
+ });
+ this._portalHelperProxy.connectSignal('Done',
+ () => this._portalHelperDone().catch(logError));
+
+ try {
+ await this._portalHelperProxy.init_async(
+ GLib.PRIORITY_DEFAULT, null);
+ } catch (e) {
+ console.error(`Error launching the portal helper: ${e.message}`);
+ }
}
+ this._portalHelperProxy?.AuthenticateAsync(path, '', timestamp).catch(logError);
+
this._connectivityQueue.push(path);
}
this._proxy = null;
}
- enrollDevice(id, policy, callback) {
- this._proxy.EnrollDeviceRemote(id, policy, AuthCtrl.NONE, (res, error) => {
- if (error) {
- Gio.DBusError.strip_remote_error(error);
- callback(null, error);
- return;
- }
-
- let [path] = res;
- let device = new BoltDeviceProxy(Gio.DBus.system,
- BOLT_DBUS_NAME,
- path);
- callback(device, null);
- });
+ async enrollDevice(id, policy) {
+ try {
+ const [path] = await this._proxy.EnrollDeviceAsync(id, policy, AuthCtrl.NONE);
+ const device = new BoltDeviceProxy(Gio.DBus.system, BOLT_DBUS_NAME, path);
+ return device;
+ } catch (error) {
+ Gio.DBusError.strip_remote_error(error);
+ throw error;
+ }
}
get authMode() {
this._enrollDevicesIdle.bind(this));
}
- _onEnrollDone(device, error) {
- if (error)
- this.emit('enroll-failed', device, error);
-
- /* TODO: scan the list of devices to be authorized for children
- * of this device and remove them (and their children and
- * their children and ....) from the device queue
- */
- this._enrolling = this._devicesToEnroll.length > 0;
-
- if (this._enrolling) {
- GLib.idle_add(GLib.PRIORITY_DEFAULT,
- this._enrollDevicesIdle.bind(this));
- }
- }
-
- _enrollDevicesIdle() {
+ async _enrollDevicesIdle() {
let devices = this._devicesToEnroll;
let dev = devices.shift();
if (dev === undefined)
return GLib.SOURCE_REMOVE;
- this._client.enrollDevice(dev.Uid,
- Policy.DEFAULT,
- this._onEnrollDone.bind(this));
+ try {
+ await this._client.enrollDevice(dev.Uid, Policy.DEFAULT);
+
+ /* TODO: scan the list of devices to be authorized for children
+ * of this device and remove them (and their children and
+ * their children and ....) from the device queue
+ */
+ this._enrolling = this._devicesToEnroll.length > 0;
+
+ if (this._enrolling) {
+ GLib.idle_add(GLib.PRIORITY_DEFAULT,
+ this._enrollDevicesIdle.bind(this));
+ }
+ } catch (error) {
+ this.emit('enroll-failed', null, error);
+ }
return GLib.SOURCE_REMOVE;
}
};
labels.push(str ?? '');
}
- if (this._gsdWacomProxy)
- this._gsdWacomProxy.SetOLEDLabelsRemote(pad.get_device_node(), labels);
+ this._gsdWacomProxy?.SetOLEDLabelsAsync(
+ pad.get_device_node(), labels).catch(logError);
});
global.display.connect('init-xserver', (display, task) => {
}
vfunc_activate() {
- this._shellProxy.CheckForUpdatesRemote();
+ this._shellProxy.CheckForUpdatesAsync().catch(logError);
this._window.present();
}
dialog.connect('response', (dlg, response) => {
if (response === Gtk.ResponseType.ACCEPT)
- this._shellProxy.UninstallExtensionRemote(uuid);
+ this._shellProxy.UninstallExtensionAsync(uuid).catch(logError);
dialog.destroy();
});
dialog.present();
}
}
- this._shellProxy.OpenExtensionPrefsRemote(uuid,
+ this._shellProxy.OpenExtensionPrefsAsync(uuid,
this._exportedHandle,
- { modal: new GLib.Variant('b', true) });
+ {modal: new GLib.Variant('b', true)}).catch(logError);
}
_showAbout() {
this._syncListVisibility();
}
- _scanExtensions() {
- this._shellProxy.ListExtensionsRemote(([extensionsMap], e) => {
- if (e) {
- if (e instanceof Gio.DBusError) {
- log(`Failed to connect to shell proxy: ${e}`);
- this._mainStack.visible_child_name = 'noshell';
- } else {
- throw e;
- }
- return;
- }
+ async _scanExtensions() {
+ try {
+ const [extensionsMap] = await this._shellProxy.ListExtensionsAsync();
for (let uuid in extensionsMap) {
let extension = ExtensionUtils.deserializeExtension(extensionsMap[uuid]);
this._addExtensionRow(extension);
}
this._extensionsLoaded();
- });
+ } catch (e) {
+ if (e instanceof Gio.DBusError) {
+ log(`Failed to connect to shell proxy: ${e}`);
+ this._mainStack.visible_child_name = 'noshell';
+ } else {
+ throw e;
+ }
+ }
}
_addExtensionRow(extension) {
action.connect('activate', toggleState);
action.connect('change-state', (a, state) => {
if (state.get_boolean())
- this._app.shellProxy.EnableExtensionRemote(this.uuid);
+ this._app.shellProxy.EnableExtensionAsync(this.uuid).catch(logError);
else
- this._app.shellProxy.DisableExtensionRemote(this.uuid);
+ this._app.shellProxy.DisableExtensionAsync(this.uuid).catch(logError);
});
this._actionGroup.add_action(action);